import {
    _get,
    _post
} from '../../utils/request'
import util from '../../utils/util'
const app = getApp()
Page({
    data: {},
    formSubmit(e) {
        let pwd = e.detail.value.newpwd
        let pwd2 = e.detail.value.newpwd2
        let old = e.detail.value.oldpwd
        if (pwd == pwd2) {
            let params = {
                newPassword: pwd,
                oldPassword: old,
                userId: app.userId
            }
            console.log(params);
            _post(`/set/update`, params).then(res => {
                dd.alert({
                    content: res.message,
                    buttonText: '确认',
                    success: () => {
                        dd.reLaunch({
                            url: '/pages/set/set'
                        })
                    }
                })
            })

        } else {
            dd.alert({
                content: '前后输入不一致，请重新输入！',
                buttonText: '确认',
            })
        }
    },
    onLoad() {},
});